package com.aps.demo.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import java.util.List;

/**
 * 约束条件数据模型
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "约束条件数据模型")
public class Constraint {
    
    @JsonProperty("hardConstraints")
    @Schema(description = "硬约束条件列表")
    private List<HardConstraint> hardConstraints;
    
    @JsonProperty("softConstraints")
    @Schema(description = "软约束条件列表")
    private List<SoftConstraint> softConstraints;
    
    /**
     * 硬约束条件
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "硬约束条件")
    public static class HardConstraint {
        
        @NotBlank(message = "约束ID不能为空")
        @JsonProperty("constraintId")
        @Schema(description = "约束ID", example = "HC001")
        private String constraintId;
        
        @NotBlank(message = "约束类型不能为空")
        @JsonProperty("constraintType")
        @Schema(description = "约束类型", example = "设备产能约束")
        private String constraintType;
        
        @NotBlank(message = "约束描述不能为空")
        @JsonProperty("description")
        @Schema(description = "约束描述", example = "注塑机日产能不超过1000件")
        private String description;
        
        @NotBlank(message = "优先级不能为空")
        @JsonProperty("priority")
        @Schema(description = "优先级", example = "高")
        private String priority;
        
        /**
         * 约束类型枚举
         */
        @Schema(description = "约束类型枚举")
        public enum ConstraintType {
            EQUIPMENT_CAPACITY("设备产能约束"),
            PERSONNEL_SKILL("人员技能约束"),
            PROCESS_SEQUENCE("工艺顺序约束"),
            DELIVERY_DATE("交期约束"),
            EQUIPMENT_MAINTENANCE("设备维护约束");
            
            private final String description;
            
            ConstraintType(String description) {
                this.description = description;
            }
            
            public String getDescription() {
                return description;
            }
        }
        
        /**
         * 优先级枚举
         */
        @Schema(description = "优先级枚举")
        public enum Priority {
            HIGH("高"),
            MEDIUM("中"),
            LOW("低");
            
            private final String description;
            
            Priority(String description) {
                this.description = description;
            }
            
            public String getDescription() {
                return description;
            }
        }
    }
    
    /**
     * 软约束条件
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "软约束条件")
    public static class SoftConstraint {
        
        @NotBlank(message = "约束ID不能为空")
        @JsonProperty("constraintId")
        @Schema(description = "约束ID", example = "SC001")
        private String constraintId;
        
        @NotBlank(message = "约束类型不能为空")
        @JsonProperty("constraintType")
        @Schema(description = "约束类型", example = "成本优化约束")
        private String constraintType;
        
        @NotBlank(message = "约束描述不能为空")
        @JsonProperty("description")
        @Schema(description = "约束描述", example = "尽量降低生产成本")
        private String description;
        
        @NotNull(message = "权重不能为空")
        @DecimalMin(value = "0.0", message = "权重不能小于0")
        @DecimalMax(value = "1.0", message = "权重不能大于1")
        @JsonProperty("weight")
        @Schema(description = "权重", example = "0.8")
        private Double weight;
        
        /**
         * 约束类型枚举
         */
        @Schema(description = "软约束类型枚举")
        public enum ConstraintType {
            COST_OPTIMIZATION("成本优化约束"),
            QUALITY_IMPROVEMENT("质量提升约束"),
            EFFICIENCY_ENHANCEMENT("效率提升约束"),
            RESOURCE_UTILIZATION("资源利用率约束");
            
            private final String description;
            
            ConstraintType(String description) {
                this.description = description;
            }
            
            public String getDescription() {
                return description;
            }
        }
    }
} 